package des.wangku.operate.standard.asm;

import java.util.HashMap;
import java.util.Map;

import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * 
 * 
 * @author Sunjian
 * @version 1.0
 * @since jdk1.8
 */
public class SearchClassVisitor extends ClassVisitor implements Opcodes {
	static Logger logger = LoggerFactory.getLogger(SearchClassVisitor.class);
	
	/** des.wangku.operate.task.baidu.baidukey.WKOPETaskBaidukey */
	String classFile=null;
	/** "des/wangku/operate/standard/task/AbstractTask" */
	String parentClass=null;
	/** "Ldes/wangku/operate/standard/task/AnnoProjectTask;" */
	String annoString =null;
	
	public SearchClassVisitor(int api) {
		super(api);
	}
	@Override
	public void visit(int arg0, int arg1, String arg2, String arg3, String arg4, String[] arg5) {
		if (parentClass!=null && parentClass.equals(arg4)) classFile = arg2.replace('/', '.');
	}
	Map<String, Object> map = new HashMap<>();

	@Override
	public AnnotationVisitor visitAnnotation(String arg0, boolean arg1) {
		if (annoString!=null && annoString.equals(arg0)) {
			AnnotationValueVisitor avv = new AnnotationValueVisitor();
			this.map = avv.map;
			return avv;
		}
		return null;
	}
}
